<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>09-循环定时器案例</title>
</head>
<body>
<script>
    // 定义循环定时器
    setInterval(function () {
        var date = new Date();
        // 格式转换
        var fullYear = date.getFullYear();
        var month = date.getMonth();
        if (month<=8){
            month="0"+(month+1);
        }
        var date1 = date.getDate();
        var hours = date.getHours();
        if (hours<=9){
            hours="0"+hours;
        }
        var minutes = date.getMinutes();
        if (minutes<=9){
            minutes="0"+minutes;
        }
        var seconds = date.getSeconds();
        if (seconds<=9){
            seconds="0"+seconds;
        }
        document.close();
        document.write(fullYear+"年"+month+"月"+date1+"日 "+hours+"时"+minutes+"分"+seconds+"秒"+"<br>");
    },1000)
</script>
</body>
</html>